//package com.project.stream_consumer.demo5.controller;
//
//import com.rabbitmq.client.Channel;
//import org.springframework.amqp.support.AmqpHeaders;
//import org.springframework.cloud.stream.annotation.EnableBinding;
//import org.springframework.cloud.stream.annotation.StreamListener;
//import org.springframework.cloud.stream.messaging.Sink;
//import org.springframework.messaging.Message;
//import org.springframework.messaging.handler.annotation.Header;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.util.concurrent.TimeUnit;
//
//@Component
//@EnableBinding(Sink.class)
//public class ConsunmerController {
//    @StreamListener(Sink.INPUT)
//    public void input(Message<String> message, @Header(AmqpHeaders.CHANNEL) Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag){
////        try {
////            //TimeUnit.SECONDS.sleep(2);
////        } catch (InterruptedException e) {
////            e.printStackTrace();
////        }
//        String payload = message.getPayload();
//        System.out.println("消费者A:"+ payload);
//        try {
//            System.out.println("消费者A消费了:" + payload);
//            channel.basicAck(deliveryTag, true);//消息手动确认，如配置了预读取prefetch=3，在消费完这三条后未确认，将不再去MQ中拉取;
//            //如果第二个参数配置为true ,生产者一次发送1~10，但2这条消息不去basicAck确认消费，在消费后一条时，会默认消费掉2这条消息；
//            //配置为false时，basicAck只会确认传入的消息，之前未确认消费的消息不会消费，消息还可以继续被重复消费
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//}
